{##
 # TODO: description
 #
 # @copyright  Copyright (c) 2010-2012 The Fajr authors (see AUTHORS).
 #             Use of this source code is governed by a MIT license that can be
 #             found in the LICENSE file in the project root directory.
 # @author     TODO
 #}
{% extends "layout/studium.html.twig" %}
{% block title %}Moje skúšky{% endblock %}
{% block application_content %}
{% import "macros/decorators.html.twig" as decorators %}
{% import "macros/mobile_decorators.html.twig" as mobile_decorators %}
{% import "macros/table.html.twig" as table %}
{% import "macros/studium.html.twig" as studiumMacros %}
{{ parent() }}
{% set tabContent %} 

  {% macro tabulkaSkuska(row, odhlas, studium, zapisnyList) %}
    {% import "macros/decorators.html.twig" as decorators %}
    {% import "macros/mobile_decorators.html.twig" as mobile_decorators %}
    {% set title %}
      {{mobile_decorators.span((row.predmetNazov|escape)~" - "~(row.dat|escape),"table_box_title")}}
    {% endset %}
    {% set content %}
    <div class="table_box">
      <ul class="table_box">     
        {{ mobile_decorators.riadok("Čas:", row.cas|escape) }}
        {{ mobile_decorators.riadok("Dátum:", row.dat|escape) }}
        {{ mobile_decorators.riadok("Miestnosť:", row.miestnosti|escape) }}
        {{ mobile_decorators.riadok("Hodnotiaci:", row.hodnotiaci|escape) }}
        {{ mobile_decorators.riadok("Počet prihlásených:", row.pocetPrihlasenych|escape) }}
        {{ mobile_decorators.riadok("Maximálny počet:", row.maxPocet|escape) }}
        {{ mobile_decorators.riadok("Poznámka:", row.poznamka|escape) }}
        {{ mobile_decorators.riadok("Prihlasovanie:", row.prihlasovanie|escape) }}
        {{ mobile_decorators.riadok("Odhlasovanie:", row.odhlasovanie|escape) }}
        {{ mobile_decorators.riadok("Odhlás:", odhlas) }}
        {{ mobile_decorators.riadok("Známka:", row.znamka|escape) }}
        <li><a href={{ path('studium_moje_skusky', {
                          'studium': studium,
                          'list': zapisnyList,
                          'termin': row.index}) }} class="last">Zoznam prihlásených</a></li>
      </ul>      
    </div>
    {% endset %}      
    {{ decorators.collapsible(title, content, true) }}
  {% endmacro %}

 
  {% set body %}
    {% for row in terminyActive %}      
        {% if row.mozeOdhlasit %}
          {% set class="terminmozeodhlasit" %}
          {% set odhlas %}
            <form method="post" action="{{ path('studium_odhlas_zo_skusky',
                                                {'studium': studium,
                                                'list': zapisnyList}) }}">
              <div>
                <input type="hidden" name="odhlasIndex" value="{{ row.index }}" />
                <input type="hidden" name="hash" value="{{ row.hashNaOdhlasenie }}"/>
                <button name="submit" type="submit" class="tableButton negative">
                  <img src="images/third_party/silk/cross.png" alt="" />Odhlás
                </button>
              </div>
            </form>
          {% endset %}
        {% else %}
          {% set class="terminnemozeodhlasit" %}
          {% set odhlas="nedá sa" %}
        {% endif %}
        {% if row.jePrihlaseny != 'TRUE' %}
          {% set class="terminodhlaseny" %}
          {% set odhlas="Si odhlásený. Ak chceš, opäť sa prihlás." %}
        {% endif %}
        {{ _self.tabulkaSkuska(row,  odhlas, studium, zapisnyList) }}
    {% endfor %}
  {% endset %}  

  {% set title %}
    <h2>Aktuálne termíny hodnotenia</h2>
  {% endset %}

  {% set tableHTML %}
  {{ mobile_decorators.printbox(body, terminyActive|length == 0) }}
  {% endset %}

  {{ decorators.collapsible(title, tableHTML, false) }}

  {# -- stare terminy #}

  {% set body %}
    {% for row in terminyOld %}      
        {{ _self.tabulkaSkuska(row, "Skúška už bola.", studium, zapisnyList) }}
    {% endfor %}
  {% endset %}

  {% set title %}
    <h2>Staré termíny hodnotenia</h2>
  {% endset %}

  {% set tableHTML %}
  {{ mobile_decorators.printbox(body, terminyOld|length == 0) }}
  {% endset %}

  {{ decorators.collapsible(title, tableHTML, false) }}

  {# -- zoznam prihlasenych na termin #}
  {{ studiumMacros.zoznamPrihlasenych(prihlaseni) }}

{% endset %}

{{ studiumMacros.studiumTabs(tabContent, 'TerminyHodnotenia', studium, zapisnyList) }}

{% endblock %}
